package com.scitc.pleasurevideo.helper;

import android.app.Activity;
import android.content.Intent;

import com.scitc.pleasurevideo.ParsingActivity;
import com.scitc.pleasurevideo.PlayVideoActivity;
import com.scitc.pleasurevideo.R;
import com.scitc.pleasurevideo.SearchActivity;
import com.scitc.pleasurevideo.data.UserDataMan;
import com.scitc.pleasurevideo.woview.CollectActivity;
import com.scitc.pleasurevideo.woview.HistoryActivity;
import com.scitc.pleasurevideo.woview.LoginActivity;
import com.scitc.pleasurevideo.woview.SettingActivity;
import com.scitc.pleasurevideo.Tabhome;
import com.scitc.pleasurevideo.TvMenuContentActivity;
import com.scitc.pleasurevideo.WebviewPlayActivity;
import com.scitc.pleasurevideo.pojo.DoubanTvVo;
import com.scitc.pleasurevideo.pojo.MenuTvVo;
import com.scitc.pleasurevideo.pojo.PlayMenuTvVo;
import com.scitc.pleasurevideo.woview.SettingVideoSourceListActivity;
import com.scitc.pleasurevideo.woview.UserSettingVideoSourceActivity;

import java.io.Serializable;
import java.util.List;

/**
 * @author 853
 */
public class ForwardHelper {
    /**
     * 去首页
     *
     * @param activity
     */
    public static void toMain(Activity activity) {
        Intent intent = new Intent(activity, Tabhome.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 打开搜索界面
     *
     * @param activity
     */
    public static void toSearchActivity(Activity activity) {
        Intent intent = new Intent(activity, SearchActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 去影视资源列表
     *
     * @param activity
     * @param doubanTvPojo
     */
    public static void toTvMenuContentActivity(Activity activity, DoubanTvVo doubanTvPojo) {
        Intent intent = new Intent(activity, TvMenuContentActivity.class);
        intent.putExtra("doubanTvPojo", doubanTvPojo);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 去影视集数列表
     *
     * @param activity
     * @param doubanTvPojo
     */
    public static void toTvPlayMenuActivity(Activity activity, DoubanTvVo doubanTvPojo, MenuTvVo menuTvPojo) {
//        Intent intent=new Intent(activity, TvPlayMenuActivity.class);
        Intent intent = new Intent(activity, PlayVideoActivity.class);
        intent.putExtra("doubanTvPojo", doubanTvPojo);
        intent.putExtra("menuTvPojo", menuTvPojo);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 去影视集数列表
     *
     * @param activity
     * @param doubanTvPojo
     */
    public static void toTvPlayMenuActivity(Activity activity, DoubanTvVo doubanTvPojo, MenuTvVo menuTvPojo, List<PlayMenuTvVo> playMenuTvPojos) {
//        Intent intent=new Intent(activity, TvPlayMenuActivity.class);
        Intent intent = new Intent(activity, PlayVideoActivity.class);
        intent.putExtra("menuTvPojo", menuTvPojo);
        intent.putExtra("doubanTvPojo", doubanTvPojo);
        intent.putExtra("items", (Serializable) playMenuTvPojos);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 打开各大视频网页
     *
     * @param activity
     * @param weburl
     */
    public static void toParsingActivity(Activity activity, String weburl) {
        Intent intent = new Intent(activity, ParsingActivity.class);
        intent.putExtra("url", weburl);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 打开播放视频的网页界面
     *
     * @param activity
     * @param playUrl
     * @param playName
     */
    public static void toWebviewPlayActivity(Activity activity, String playUrl, String playName) {
        Intent intent = new Intent(activity, WebviewPlayActivity.class);
        intent.putExtra("playUrl", playUrl);
        intent.putExtra("playName", playName);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }

    /**
     * 打开设置界面
     * @param activity
     */
    public static void toSettingActivity(Activity activity){
        Intent intent = new Intent(activity, SettingActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
    /**
     * 打开设置影视资源列表
     * @param activity
     */
    public static void toSettingVideoSourceListActivity(Activity activity){
        Intent intent = new Intent(activity, SettingVideoSourceListActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
    /**
     * 打开设置影视资源列表（管理员）
     * @param activity
     */
    public static void toUserSettingVideoSourceActivity(Activity activity){
        if(UserDataMan.init().getUser()==null){
            return;
        }
        Intent intent = new Intent(activity, UserSettingVideoSourceActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
    /**
     * 打开登录界面
     * @param activity
     */
    public static void toLoginActivity(Activity activity){
        Intent intent = new Intent(activity, LoginActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
    /**
     * 打开历史记录界面
     * @param activity
     */
    public static void toHistoryActivity(Activity activity){
        Intent intent = new Intent(activity, HistoryActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
    /**
     * 打开收藏界面
     * @param activity
     */
    public static void toCollectActivity(Activity activity){
        Intent intent = new Intent(activity, CollectActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        activity.startActivity(intent);
        activity.overridePendingTransition(R.anim.activity_open_in_anim,
                R.anim.activity_open_out_anim);
    }
}
